package cn.zyy.hotel.exception;

import cn.zyy.hotel.utils.SystemConstant;
import org.apache.shiro.authz.AuthorizationException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@ControllerAdvice
public class ExceptionConfig {

    @ExceptionHandler(AuthorizationException.class)
    @ResponseBody
    public Object authorizationException(Exception e){
        Map<String, Object> map = new HashMap<>();
        map.put(SystemConstant.SUCCESS,false);
        map.put(SystemConstant.MESSAGE,"您没有权限操作,请联系管理员");
        return map;
    }

}
